// pages/publish_payment/publish_payment.js
Page({

  data: {
    isActive:true,
    money:'',
  },


  // 响应函数  主要是为了设置选中的样式
  choosePayment(e){
    // console.log(e.currentTarget.id);
    const paymentType = e.currentTarget.id;

    if(paymentType==='free'){
      this.setData({
        isActive:true
      })
    }else{
      this.setData({
        isActive:false,
      })
    }
  },


  // 输入票种金额
  handleMoney(e){
    const that = this;
    // console.log(e.detail.value);
    if(e.detail.value<=0){
      wx.showModal({
        title: '提示',
        content: '请输入有效金额',
        showCancel: false,
        cancelColor: '#000000',
        confirmText: '知道了',
        confirmColor: '#3CC51F',
        success: (result) => {
          if (result.confirm) {
            that.setData({
              money:''
            })
            return
          }
        },

      });
    }
    this.setData({
      money:e.detail.value
    })
  },


  // 保存返回到编辑页面
  submit(){
    wx.setStorageSync('payment', Number(this.data.money));
    wx.switchTab({
      url: '/pages/publish/publish',
    });
  }
})